package com.fengxu.springcloud.controller;

import com.fengxu.springcloud.entity.CommonResult;
import com.fengxu.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    // 模拟数据库中的数据
    private static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L, new Payment(1L,"sadewasd12xqwe123sads"));
        hashMap.put(2L, new Payment(2L,"w332dsadd12xqwe123sad"));
        hashMap.put(3L, new Payment(3L,"4asderwsd12xqwe123sad"));
    }

    @GetMapping("/find/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){
        Payment payment = hashMap.get(id);
        return new CommonResult<>(200,"from mysql server-port = " + serverPort, payment);
    }

}
